package com.jf.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestController {

    private Map<String,String> map = new HashMap<>();

    //防止表单重复提交后端处理。存入缓存
    @RequestMapping("/test")
    public String test(String name){
        //模仿第一次提交
        String token = "token";
        //假设存放缓存
        if (map.get(token)!=null){
            return "表单已经被提交过了！！！";
        }
        map.put(token,token);
        return "注册成功!!!"+name;
    }

    //幂等

    /**
     * https://www.iteye.com/blog/825635381-2276077
     */
    @RequestMapping("/miDeng")
    public String miDeng(String name){ return null; }
}
